<?php
/**
 * 维护配送地区，不同地区库存不同
 */
define('IN_ECS', true);
require(dirname(__FILE) . '/includes/init.php');

$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : '';
if($act === 'refresh'){
	$goodsId  = isset($_REQUEST['goodsId']) ? $_REQUEST['goodsId'] : 1077;   //这个1077有待考虑
	/*地区信息全部确定后*/
	$provinceId  = isset($_REQUEST['provinceId']) ? $_REQUEST['provinceId'] : 1006;
    $cityId      = isset($_REQUEST['cityId']) ? $_REQUEST['cityId'] : 1007;
    $districtId  = isset($_REQUEST['districtId']) ? $_REQUEST['districtId'] : 1013;
	$_SESSION['consignee'] = array(
	        'provinceId' =>$provinceId,
	        'province_name' => selectaddress($provinceId),
	        'cityId'     =>$cityId,
	        'city_name'     => selectaddress($cityId),
	        'districtId' =>$districtId,
	        'district_name' =>selectaddress($districtId),
	);
	$_SESSION['area_id'] = is_buy($_SESSION['consignee'])?is_buy($_SESSION['consignee']):1;  //更新area_id

	header('Location: goods-detail-' . $goodsId);
}
else{
	//只处理地区
	$region_id = isset($_REQUEST['id'])  ? intval($_REQUEST['id']) : 1;

	$response['response'] = 'region';
	$response['region'] = tourlencode( get_regions($region_id) );

	echo  tourldecode($response) ;
}


?>